let exploreComponent = {
    template: `
        <div class="explore page">
            <div class="head">
                <div class="left"></div>
                <div class="title">MINDLIV</div>
                <div class="right"></div>
            </div>
            <div class="main">
                <div class="category" v-show="c.list.length" v-for="c in categoryList">
                    <div class="category-name">
                        {{c.name}}
                    </div>
                    <div class="scroll-box">
                        <div class="sessions" >
                            <div class="item" v-for="item in c.list" @click="handleClick(item)">
                                <div class="item-name">{{item.name}}</div>
                                <div class="publisher">{{item.description}}</div>
                         
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="foot">
                <div class="btn" @click="toPage('history')">history</div>
                <div class="btn" @click="toPage('profile')">profile</div>
            </div>
        </div>
    `,
    data() {
        return {
            categoryList:[]
        }

    },
    computed: {},
    watch: {},
    mounted() {
        treatmentSession.getList(JSON.stringify({
            state:Number(this.$route.query.state) || 2
        })).then((entities)=>{

            entities.sort(function(a,b){return b.id-a.id});
            category.getList().then((result)=>{
                result.forEach((c)=>{
                    c.list = []
                    entities.forEach((t)=>{
                        if(t.categoryId === c.id){
                            c.list.push(t)
                        }
                    })
                    this.categoryList.push(c)
                })
            })
        })
    },
    activated() {

    },
    methods: {
        toPage(page){
            this.$router.push({
                name:page
            })
        },
        handleClick(item){
            this.$router.push({
                name:'detail',
                query:{
                    sessionId: item.id
                }
            })
        }
    },
    components: {},
    beforeRouteLeave(to, from, next) {

        next();
    }
}

